﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class zhuantai : Form
    {
        public zhuantai()
        {
            InitializeComponent();
        }
        public string dcid;
        string constr = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";

        private void zhuantai_Load(object sender, EventArgs e)
        {
            string sql = @"SELECT  [Ordering management].dcCzid, commodity.spName, [Ordering management].dcJine
FROM      commodity INNER JOIN
                   [Ordering management] ON commodity.spID = [Ordering management].dcName  where dcID="+dcid+"";
            SqlConnection sqlcon = new SqlConnection(constr);
            sqlcon.Open();
            SqlCommand sqlcom = new SqlCommand(sql,sqlcon);
            SqlDataReader reader = sqlcom.ExecuteReader();
            if (reader.Read())
            {
                label5.Text = Convert.ToString(reader["dcCzid"]);
                label6.Text = Convert.ToString(reader["spName"]);
                label7.Text = Convert.ToString(reader["dcJine"]);

            }
            sqlcon.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string cz=textBox1.Text;
            string sql = "update [Ordering management] set dcCzid=" + cz + " where dcID="+dcid+"";
            SqlConnection sqlcon = new SqlConnection(constr);
            sqlcon.Open();
            SqlCommand sqlcom = new SqlCommand(sql,sqlcon);
            if (sqlcom.ExecuteNonQuery()>0)
            {
                MessageBox.Show("1");
            }
            
            sqlcon.Close();
            
            this.Close();
        }

    }
}
